﻿@model Sheng.WeixinConstruction.Management.Shell.Models.MovieTimesViewModel

@{
    ViewBag.MainMenu = "Portal";
    ViewBag.LeftMenu = "MovieTimes";

    ViewBag.Title = "电影排片";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

    $(document).ready(function () {
        if (_online == false)
            return;

        $("[keyenter]").keypress(function (e) {
            if (e.keyCode == 13) {
                save();
            }
        });

        $("#txtShareImageUrl").blur(function () {
            loadShareImage();
        });

        loadShareImage();

    });

    @if (ViewBag.Domain.Type != Sheng.WeixinConstruction.Infrastructure.EnumDomainType.Free)
    {
        <text>
    function save() {


        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        var args = new Object();
        args.ShareImageUrl = $("#txtShareImageUrl").val();
        args.ShareTimelineTitle = $("#txtShareTimelineTitle").val();
        args.ShareAppMessageTitle = $("#txtShareAppMessageTitle").val();
        args.ShareAppMessageDescription = $("#txtShareAppMessageDescription").val();

        var url = "/Api/Movie/SaveSettings";

        $.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data: JSON.stringify(args),
            success: function (data, status, jqXHR) {
                layer.close(loadLayerIndex);
                if (data.Success) {
                    layerAlert("保存成功，您的设置将在几分钟之内生效。");
                } else {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest) {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

    </text>
    }


    function uploadShareImage() {
        __showFileUpload(getUploadShareImageResult);
    }

    function getUploadShareImageResult(fileServiceAddress, result) {
        var url = fileServiceAddress + result.Data.StoreFilePath;
        $("#txtShareImageUrl").val(url);
        loadShareImage();
    }

    function loadShareImage() {
        $("#shareImage").attr("src", $("#txtShareImageUrl").val());
    }

    function removeShareImage() {
        $("#txtShareImageUrl").val("");
        loadShareImage();
    }

</script>



<style type="text/css">
    .divBaseSettingsTitle {
        margin-top: 25px;
        margin-left: 10px;
        margin-right: 10px;
    }

    .divBaseSettings {
        margin-top: 20px;
        margin-left: 10px;
        margin-right: 10px;
    }
</style>


<div>
    <form id="form">
        <div class="divBaseSettingsTitle font_black_22">
            设置
        </div>

        <div class="divDotLine" style="margin-top:10px; width:400px;"></div>

        @if (String.IsNullOrEmpty(Model.Settings.MTimeUrl) == false)
        {
            <div class="divBaseSettings">
                已完成对接，系统将自动生成每日排片表；您可以在 菜单设置 中，添加 电影排片 菜单，即可在微信端进行查询。
            </div>
            <div class="divBaseSettings" style="margin-top:10px;">
                也可将此 URL 配置到您的其它服务号或订阅号菜单中以查看排片信息：<br />
            </div>
            <div class="divBorder_lightgray" style="margin-top:10px;margin-left: 10px;margin-right: 10px; padding:10px;font-size:13px;">
                http://@(ViewBag.DomainContext.AppId).wxc.shengxunwei.com/Home/MovieTimes/@(ViewBag.Domain.Id)
            </div>
        }
        else
        {
            <div class="divBaseSettings">
                请联系我们进行电影排片对接，对接后系统将自动生成每日排片表。
            </div>
        }

        <div class="divBaseSettings">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td height="110" valign="top">

                        <div style="margin-top: 5px;">
                            分享小图片：
                        </div>
                    </td>
                    <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="110">
                                    <img id="shareImage" src="" alt="" width="100" height="100" />
                                </td>
                                <td>
                                    <a href="javascript:void(0)" onclick="uploadShareImage()">上传新图片</a><br />
                                    <a href="javascript:void(0)" onclick="removeShareImage()">删除图片</a>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td height="36">&nbsp;</td>
                    <td>
                        <input id="txtShareImageUrl" name="txtShareImageUrl" type="text" class="input_16" style="width: 96%;" maxlength="500" value="@Model.Settings.ShareImageUrl" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td valign="top">
                        <div class="font_gray_13" style="width: 96%; margin-bottom: 10px;">
                            在微信中分享活动时，使用的正方形小图片。
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="140" height="36">分享到朋友圈标题：</td>
                    <td>
                        <input id="txtShareTimelineTitle" name="txtShareTimelineTitle" type="text" class="input_16" style="width: 96%;" maxlength="50" value="@Model.Settings.ShareTimelineTitle" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <div class="font_gray_13" style="width: 96%; margin-bottom: 10px;">
                            将活动页面分享到朋友圈时显示的标题文字。
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="140" height="36">分享给好友标题：</td>
                    <td>
                        <input id="txtShareAppMessageTitle" name="txtShareAppMessageTitle" type="text" class="input_16" style="width: 96%;" maxlength="50" value="@Model.Settings.ShareAppMessageTitle" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <div class="font_gray_13" style="width: 96%; margin-bottom: 10px;">
                            将活动页面分享给好友时显示的标题文字。
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="140" height="36">分享给好友描述：</td>
                    <td>
                        <input id="txtShareAppMessageDescription" name="txtShareAppMessageDescription" type="text" class="input_16" style="width: 96%;" maxlength="100" value="@Model.Settings.ShareAppMessageDescription" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <div class="font_gray_13" style="width: 96%; margin-bottom: 10px;">
                            将活动页面分享给好友时显示的标题下方的一段描述文字。
                        </div>
                    </td>
                </tr>

            </table>
        </div>

        <div style=" margin-top:15px;">
            @if (ViewBag.Domain.Type != Sheng.WeixinConstruction.Infrastructure.EnumDomainType.Free)
            {
                <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="保存" onclick="save()" />
            }
            else
            {
                <input name="btnSave" type="button" class="btn_blue" id="btnSave" value="保存" disabled />
                @Helpers.VipIcon()
            }
        </div>
    </form>
</div>

@Helpers.FileUpload()